package com.dunqi.gpm.cangxi.home.widget;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.dunqi.gpm.cangxi.R;
import com.dunqi.gpm.cangxi.develop.bean.News;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 空 on 2017/11/22 0022.
 */

public class ProjectTrendView extends FrameLayout {

    @BindView(R.id.public_name_tv)
    NormalView publicNameTv;
    @BindView(R.id.public_organization_tv)
    NormalView publicOrganizationTv;
    @BindView(R.id.public_time_tv)
    NormalView publicTimeTv;
    @BindView(R.id.trend_status_tv)
    NormalView trendStatusTv;
    @BindView(R.id.trend_marked_tv)
    NormalView trendMarkedTv;
    @BindView(R.id.title_tv)
    NormalView titleTv;
    @BindView(R.id.trend_content_tv)
    TextView contentTv;
    @BindView(R.id.right_arraw_iv)
    ImageView rightArrawIv;

    String[] titles = {"创建", "待审核", "审核通过", "审核未通过"};
    String[] trendTypes = {"conf_conclusion", "conf_record", "manager_command", "news", "announcement", "inspection", "other"};
    String[] trendTypeTexts = {"会议决议", "会议记录", "领导批示", "新闻", "公告", "检查", "其它"};

    public ProjectTrendView(@NonNull Context context) {
        super(context);
    }

    public ProjectTrendView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.project_trend, this);
        ButterKnife.bind(this);
    }


    public void setData(News item) {
        publicNameTv.setText(item.getIssuePersonId() + "");
        publicTimeTv.setText(item.getIssueTime());
        publicOrganizationTv.setText(item.getIssueOrgId() + "");

        String trendType = item.getTrendType();
        for (int i = 0; i < trendTypes.length; i++) {
            if (!trendTypes[i].equals(trendType)) {
                trendStatusTv.setText(trendTypeTexts[i]);
            }
        }

        int status = item.getAuditStatus();

        trendMarkedTv.setText(titles[status]);
        titleTv.setText(item.getTrendTitile());

        contentTv.setText(item.getTrendContent());

    }
}
